import Vanilla.UI

// PANEL ITEM
class PanelItem (Frame):
	def constructor (p as Box):
		super(p)
		DrawFrame = false
	
	override def Contains (x as double, y as double):
		return Size.Contains(x,y)
	
	override def ContainsMouseAt (x as double, y as double):
		return Contains(x,y)

// PANEL
class Panel (Row):
	public Left as Row
	public Right as Row
	
	def constructor (d as Desktop):
		super(d)
		DrawFrame = false
		AcceptsDrops = true
		
		Left = Row(self)
		Left.DrawFrame = false
		Left.Spacing = 3
		
		Right = Row(self)
		Right.DrawFrame = false
		Right.Spacing = 3
		
		Size = Size(100,30)
	
	override def AcceptsDrop (g as Gadget, x as double, y as double) as bool:	
		print "accepts drop of ${g}? ${g isa Icon}"
		return g isa Icon
	
	override def Drop (g as Gadget, x as double, y as double):
		if g isa Icon:
			print "Droppity ${g}"
			i = g as Icon
			Left.Add(FileThumbnail(self, i.File))
			CleanUpAndEndDrag()
	
	override def Arrange ():
		unless Left == null or Right == null:
			Left.Rect = Rect(Spacing, Spacing, Left.MinSize.Width+Spacing, Size.Height-Spacing)
			Right.Rect = Rect(Size.Width-Spacing-Right.MinSize.Width, Spacing, Size.Width-Spacing, Size.Height-Spacing)
			print "Right.Rect = ${Right.Rect}"
			print "Right.MinSize = ${Right.MinSize}"
	
	override def MouseUp (b as MouseButton, x as double, y as double):
		print "Mouse uppy ${b} ${x} ${y}"
		super(b,x,y)
			
	override def Contains (x as double, y as double):
		return Size.Contains(x,y)
		
	override def ContainsMouseAt (x as double, y as double):
		return Size.Contains(x,y)
